//
//  SZViewController.m
//  TestLib
//
//  Created by 珍 宋 on 06/04/2018.
//  Copyright (c) 2018 珍 宋. All rights reserved.
//

#import "CollectionView.h"
#import "SZViewController.h"

@interface SZViewController (){

    CollectionView *view;
    
    
    NSMutableArray *_dataArray;
}

@end

@implementation SZViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    UIButton *oneBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    oneBtn.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - 55, [UIScreen mainScreen].bounds.size.width , 55);
    oneBtn.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:oneBtn];
    [oneBtn setTitle:@"添加" forState:UIControlStateNormal];
    [oneBtn addTarget:self action:@selector(clicked) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *twoBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    twoBtn.frame = CGRectMake(0, 300, [UIScreen mainScreen].bounds.size.width , 55);
    twoBtn.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:twoBtn];
    [twoBtn setTitle:@"删除" forState:UIControlStateNormal];
    [twoBtn addTarget:self action:@selector(twoClicked) forControlEvents:UIControlEventTouchUpInside];
    
    view = [[CollectionView alloc] initWithPointX:0 pointY:50 width:[UIScreen mainScreen].bounds.size.width rowNum:4 rowHeight:40];
    view.rowSpacing = 10;
//    view = [[CollectionView alloc] initWithFrame:CGRectMake(0, 50, [UIScreen mainScreen].bounds.size.width, 120) rowNumber:2];
    NSArray *array = @[@"氛围浓过我weoniwfi浓1"];
    _dataArray = [NSMutableArray array];
    for (NSString *str in array) {
        
        CellModel *model = [[CellModel alloc] initWithTitle:str];
        [_dataArray addObject:model];
    }
    [view updateData:_dataArray];
    [self.view addSubview:view];
}

- (void)clicked{
    
    CellModel *model = [[CellModel alloc] initWithTitle:@"围浓过我weongownefoiwfi"];
    [_dataArray addObject:model];
    [view updateData:_dataArray];
}

- (void)twoClicked{

    [_dataArray removeLastObject];
    [view updateData:_dataArray];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
